<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="1" data-index="2"></div>
<script>
  var div = document.querySelector('div')

  // div.id = '3';
  // div.setAttribute('index', '4');
  // div.removeAttribute('index');

  // console.log(div.id);    // => 3
  console.log(div.getAttribute('data-index'));  // => null



</script>
</body>
</html>